//
//  MeViewController.m
//  WhatsChat
//
//  Created by 檀琛 on 16/3/22.
//  Copyright © 2016年 tanchen. All rights reserved.
//

#import "MeViewController.h"
//个人信息
#import "PersonViewController.h"

@interface MeViewController ()<UITableViewDataSource,UITableViewDelegate>

//表格视图
@property (nonatomic,strong)UITableView *tableView;

@end

@implementation MeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 设置导航栏所有按钮标题和按钮图像的颜色
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    //导航栏颜色
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.2 green:0.72 blue:0.46 alpha:1];
    //设置透明度
    self.navigationController.navigationBar.translucent = YES;
    //导航栏标题
    self.navigationItem.title = @"我的";
    //设置字体
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    //设置表格视图
    self.tableView = [[UITableView alloc]initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStyleGrouped];
    [self.view addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    //设置push返回按钮标题
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"个人信息" style:UIBarButtonItemStyleDone target:nil action:nil];
    
}
//右按键点击事件
- (void)rightAction{

}
//区数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
//行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 1;
    }else if (section == 1) {
        return 2;
    }else if (section == 2) {
        return 1;
    }else {
        return 1;
    }
}
//cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    
    if (indexPath.section == 0) {
        cell.textLabel.text = @"用户名";
        
        cell.imageView.image = [UIImage imageNamed:@"iconfont-faxian"];
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.view.width - 60, 25, 30, 30)];
        imageView.image = [UIImage imageNamed:@"iconfont-faxian"];
        
        [cell addSubview:imageView];
        
    }else if (indexPath.section == 1 && indexPath.row == 0) {
    
        cell.textLabel.text = @"相册";
        
        cell.imageView.image = [UIImage imageNamed:@"iconfont-faxian"];
    }else if (indexPath.section == 1 && indexPath.row == 1) {
        
        cell.textLabel.text = @"收藏";
        
        cell.imageView.image = [UIImage imageNamed:@"iconfont-faxian"];
    }else if (indexPath.section == 2) {
        
        cell.textLabel.text = @"钱包";
        
        cell.imageView.image = [UIImage imageNamed:@"iconfont-faxian"];
    }else {
    
        cell.textLabel.text = @"设置";
        
        cell.imageView.image = [UIImage imageNamed:@"iconfont-faxian"];
    }
    
    return cell;
}

//cell的点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section == 0) {
        //点击push
        PersonViewController *personVC = [[PersonViewController alloc]init];
        
        //隐藏tabBar
        personVC.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:personVC animated:YES];
    }
}

//行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 80;
    }else {
        return 40;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
